<style scoped>
</style>
<template>
<div class="page-wrapper">
  <div class="page-wrapper__body is-list">
  <div class="page-container">
    <div class="grid-container">
      <el-row class="grid-table-tool">
        <el-col :span="18" class="tool-action">
          <el-input v-model="params.key" placeholder="/岗位名称/职能名称" @keyup.enter="onSearch" style="width:400px;margin-right:10px;">
          </el-input>
          <el-button type="primary" icon="el-icon-search" @click="onSearch">查询</el-button>

        </el-col>
        <el-col :span="6" class="tool-pagination">
        </el-col>
      </el-row>
      <el-table border class="grid-table" :data="resp.dataList" width="100%">
        <el-table-column type="index" align="center" width="50"> </el-table-column>
        <el-table-column prop="" label="操作" align="center" width="60">
          <template slot-scope="scope">
            <a href="#" title="详情" @click="onDetail(scope.row.id)"><i class="el-icon-search"></i></a>
<!--            <el-popover placement="top" width="160" v-model="scope.row.deleteVisible" >-->
<!--              <p style="line-height: 30px">确认删除？</p>-->
<!--              <div style="text-align: right; margin: 0">-->
<!--                <el-button size="mini" round type="text" @click="scope.row.deleteVisible = false">取消</el-button>-->
<!--                <el-button type="primary" round size="mini" @click="deleted(scope.row.id)">确定</el-button>-->
<!--              </div>-->
<!--              <el-button slot="reference" type="danger" plain size="small" style="margin-left:10px;">删除</el-button>-->
<!--            </el-popover>-->
            <el-button type="text" size="small" @click="onUpdate(scope.row.id)" style="margin-left: 5px;display: none">修改</el-button>
          </template>
        </el-table-column>
        <el-table-column prop="project" label="所属项目" width="200" :show-overflow-tooltip="true"></el-table-column>
        <el-table-column prop="jobTitle" label="招聘岗位" width="200"></el-table-column>
        <el-table-column prop="jobType" label="职能名称" width="150"></el-table-column>
        <el-table-column prop="jobDesc" label="岗位职责" width="150" :show-overflow-tooltip="true"></el-table-column>
        <el-table-column prop="requirement" label="任职要求" width="150" :show-overflow-tooltip="true"></el-table-column>
        <el-table-column prop="workPlace" label="工作地点" width="120" :show-overflow-tooltip="true"></el-table-column>
        <el-table-column prop="applyUrl" label="链接" ></el-table-column>
      </el-table>
      <el-row class="grid-table-tool">
        <el-col :span="12" class="tool-action">&nbsp;</el-col>
        <el-col :span="12" class="tool-pagination">
          <el-pagination background v-if="resp.total>params.pageSize"
              @size-change="handleSizeChange"
              @current-change="handleCurrentChange"
              :current-page="params.page"
              :page-sizes="[10,15, 20, 30, 40]"
              :page-size="params.pageSize"
              layout="total, sizes, prev, pager, next"
              :total="resp.total">
          </el-pagination>
        </el-col>
      </el-row>
    </div>
  </div>
  </div>
</div>
</template>

<script>
  import {findList,deleted } from "../../api/job/mengniu";
  import moment from 'moment';
  export default {
    data(){
      return{
        resp:{
          dataList:[],
          total:0
        },
        params:{
          key: '',
          sort: '',
          order: '',
          page: 1,
          pageSize: 15,
        },
        isLoading:false,
      }
    },
    methods:{
      moment,
        onUpdate(id){
            this.$router.push({
                path:'/mengniu/job/edit',
                query: {
                    id: id
                }
            })
        },
      onDetail(id){
        this.$router.push('/mengniu/job/list/'+id)
      },
      async deleted(id){
        let resp = await deleted(id);
        if(!this.qUtil.validResp(resp)){
          this.$message({type: 'error', message: '删除失败!', showClose: true});
          return false;
        }
        this.$message({type: 'success', message: '删除成功!', showClose: true});
        if(this.resp.dataList.length===1 && this.params.page>1){
          this.params.page--;
        }
        this.loadData();

      },
      onSearch(){
        this.params.page = 1;
        this.loadData();
      },
      handleSizeChange(val) {
        this.params.pageSize = val;
        this.onSearch();
      },
      handleCurrentChange(val) {
        this.params.page = val;
        this.loadData();
      },
      async loadData(){
        let resp = await findList(this.params);
        console.log("resp=>",resp)
        if(!this.qUtil.validResp(resp)){
          this.$message({type: 'error', message: '数据加载失败!', showClose: true});
          return false;
        }
        this.resp.dataList = resp.data.dataList;
        this.resp.total = resp.data.total;
      }
    },
    mounted(){
      this.loadData();
    }
  }
</script>